package cn.gaily.eduservice.service.impl;

import cn.gaily.eduservice.entity.EduTeacher;
import cn.gaily.eduservice.mapper.EduTeacherMapper;
import cn.gaily.eduservice.service.EduTeacherService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author xuchengwei
 * @since 2021-05-22
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements EduTeacherService {

    @Override
    public Map<String, Object> getTeacherFrontList(Page<EduTeacher> pageTeacher) {
        QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        baseMapper.selectPage(pageTeacher,wrapper);
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("items", pageTeacher.getRecords());
        hashMap.put("pages", pageTeacher.getPages());
        hashMap.put("current", pageTeacher.getCurrent());
        hashMap.put("size", pageTeacher.getSize());
        hashMap.put("total", pageTeacher.getTotal());
        hashMap.put("hasNext", pageTeacher.hasNext());
        hashMap.put("hasPrevious", pageTeacher.hasPrevious());
        return hashMap;

    }
}
